import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '名称',
    align: 'left',
    dataIndex: 'name',
    // 名称列显示为树形结构
   },
   {
    title: '医院',
    align: 'center',
    dataIndex: 'hospitalId_dictText',
    // 医院列不显示树形结构
    customRender: ({ text }) => {
      return text || '';
    },
   },
   {
    title: '链接',
    align: 'center',
    dataIndex: 'link'
   },
   {
    title: '分组',
    align: 'center',
    dataIndex: 'gid',
   },
   {
    title: '排序',
    align: 'center',
    dataIndex: 'sid',
   },
   {
    title: '是否有效',
    align: 'center',
    dataIndex: 'status',
    customRender: ({ text }) => {
      if (text === '1' || text === 1) {
        return '是';
      }
      if (text === '0' || text === 0) {
        return '否';
      }
      return text || '';
    },
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
	{
      label: "医院",
      field: "hospitalId",
      component: 'JDictSelectTag',
      componentProps:{
          dictCode:"nurse_hospital,name,id",
          showSearch: true,
      },
      //colProps: {span: 6},
     },
	{
      label: "名称",
      field: "name",
      component: 'Input',
      //colProps: {span: 6},
     },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '父级节点',
    field: 'pid',
    component: 'JTreeSelect',
    componentProps: {
      dict: "hot_recommend,name,id",
      pidField: "pid",
      pidValue: "0",
      hasChildField: "has_child",
    },
  },
  {
    label: '医院',
    field: 'hospitalId',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"nurse_hospital,name,id",
        showSearch: true,
     },
  },
  {
    label: '名称',
    field: 'name',
    component: 'Input',
  },
  {
    label: '选择服务',
    field: 'link',
    component: 'Input',
    slot: 'linkSlot',
  },
  {
    label: '分组',
    field: 'gid',
    component: 'Input',
    componentProps: {
      placeholder: '请输入分组',
    },
  },
  {
    label: '排序',
    field: 'sid',
    component: 'InputNumber',
    componentProps: {
      min: 0,
      style: { width: '100%' },
      placeholder: '请输入排序',
    },
  },
  {
    label: '是否有效',
    field: 'status',
    component: 'Select',
    componentProps: {
      placeholder: '请选择是否有效',
      options: [
        { label: '是', value: '1' },
        { label: '否', value: '0' },
      ],
    },
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];

// 高级查询数据
export const superQuerySchema = {
  hospitalId: {title: '医院',order: 1,view: 'list', type: 'string',dictTable: "nurse_hospital", dictCode: 'id', dictText: 'name',},
  name: {title: '名称',order: 2,view: 'text', type: 'string',},
  link: {title: '链接',order: 3,view: 'text', type: 'string',},
};


/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
